import * as ApiUtil from '@/api/index';

const api = {
  metric: ApiUtil.getI5xforyouUrl('/i5xforyou/backend/bizDashboard/metric'),
  chartGroup: ApiUtil.getI5xforyouUrl('/i5xforyou/backend/bizDashboard/chartGroup'),
  chartList: ApiUtil.getI5xforyouUrl('/i5xforyou/backend/bizDashboard/chartList'),
  saveChart: ApiUtil.getI5xforyouUrl('/i5xforyou/backend/bizDashboard/saveChart'),
  deleteChart: ApiUtil.getI5xforyouUrl('/i5xforyou/backend/bizDashboard/deleteChart'),
};

//数据
export function metric(data?: object) {
  return ApiUtil.postI5xforyou(api.metric, data);
}

export function chartGroup() {
  return ApiUtil.getI5xforyou(api.chartGroup);
}

export function chartList(data?: object) {
  return ApiUtil.getI5xforyou(api.chartList, data);
}

export function saveChart(data?: object | string) {
  return ApiUtil.postI5xforyou(api.saveChart, data);
}

export function deleteChart(data?: object | string) {
  return ApiUtil.postI5xforyou(api.deleteChart, data);
}

export interface Chart {
  id?: string;
  bizGroupValue: number;
  chartTitle: string;
  chartConfig: string;
}

export const ChartTypeJob = 'job';
export const ChartTypeDiff = 'diff';

export interface ChartConfig {
  chartType: string;
  cron: string;
  sumSerialName: string;
  series: ChartSeries[];
}

export interface ChartSeries {
  chartId: string;
  serialId: string;
  serialName: string;
  executorType: string;
}

export interface ChartGroup {
  bizGroup: string;
  bizGroupValue: number;
}
